package com.iman.Confucius.service.impl.student;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.iman.Confucius.mappers.models.DrmBuyOrder;
import com.iman.Confucius.mappers.models.DrmBuyOrderDetail;
import com.iman.Confucius.service.student.DrmBuyOrderMapper;
import com.iman.common.hibernate.HibernateSupport;
import com.iman.common.hibernate.TemplateQLService;

@Service("drmBuyOrderMapperService")
public class DrmBuyOrderMapperServiceImpl implements DrmBuyOrderMapper{

	@Inject
    TemplateQLService templateQLService;

    @Inject
    HibernateSupport  hibernateSupport;

	@Override
	public int deleteByPrimaryKey(String orderId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(DrmBuyOrder record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public DrmBuyOrder selectByPrimaryKey(String orderId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<DrmBuyOrder> selectAll(Long user_id,String orderSt) {
		// TODO Auto-generated method stub
		Map<String,Object> params1 = new HashMap<String, Object>();
		params1.put("user_id", user_id);
		params1.put("orderSt", orderSt);
		
		List<DrmBuyOrder> buyOrder = templateQLService.findBySQLBeanQuery("order-selectall", params1, DrmBuyOrder.class);
		for(DrmBuyOrder order:buyOrder){
			Map<String,String> params = new HashMap<String, String>();
			params.put("order_id", order.getOrderId());
			List<DrmBuyOrderDetail> detailOrder = templateQLService.findBySQLBeanQuery("order-selectallDetail", params, DrmBuyOrderDetail.class);
		    order.setDetailOrderList(detailOrder);
		}
		
		return buyOrder;
	}

	@Override
	public int updateByPrimaryKey(DrmBuyOrder record) {
		// TODO Auto-generated method stub
		return 0;
	}
	
}
